package com.example.bootdemo.mq.consumer;

import com.alibaba.fastjson.JSON;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.apache.rocketmq.spring.core.RocketMQPushConsumerLifecycleListener;
import org.springframework.stereotype.Component;

//@Component
//@RocketMQMessageListener(
//        consumerGroup = "${rocketmq.consumer.group}",
//        topic = "${rocketmq.producer.topic}",
//        consumeMode= ConsumeMode.CONCURRENTLY,
//        selectorType = SelectorType.TAG,
//        selectorExpression = "tag0")
public class Tag0Consumer implements RocketMQListener<String>, RocketMQPushConsumerLifecycleListener {
    @Override
    public void onMessage(String message) {
        System.out.println("Received tag0 message : "+ message);
    }


    @Override
    public void prepareStart(DefaultMQPushConsumer consumer) {
      //  consumer.setInstanceName("user-topic");
        System.out.println( consumer );
    //  System.out.println(JSON.toJSONString(consumer)+" *******"+JSON.toJSONString(consumer));
    }
}
